﻿using System;
using System.Windows.Forms;

namespace WLWCreateCalendarItemPlugin
{
    public partial class FormOptions : Form
    {
        Settings PluginSettings;

        public FormOptions(Settings settings)
        {
            InitializeComponent();

            PluginSettings = settings;
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            PluginSettings.CalendarFolderName = ((MapiFolder)cboCalendar.SelectedItem).FullPath;
            PluginSettings.CalendarDisplayName = ((MapiFolder)cboCalendar.SelectedItem).DisplayName;
            PluginSettings.ReplaceExistingAppointment = cbOverwriteExistingCalendarEntries.Checked;

            Close();
        }

        private void FormOptions_Load(object sender, EventArgs e)
        {
            cboCalendar.DataSource = new BindingSource(OutlookUtility.LoadCalendarFolders(), null);
            cboCalendar.SelectedIndex = cboCalendar.FindStringExact(PluginSettings.CalendarDisplayName);

            // Unused - but may be in the future
            cbOverwriteExistingCalendarEntries.Checked = PluginSettings.ReplaceExistingAppointment;
        }
    }
}
